package com.cracker.sso.controller;

import com.cracker.sso.dto.response.UserDto;
import com.cracker.sso.service.TokenService;
import com.tool.base.base.BaseDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class ApiController {
    @Autowired
    private TokenService tokenService;

    @GetMapping("verifyToken")
    public BaseDto<UserDto> verifyToken(@RequestParam(name = "token") String token) {
        return new BaseDto<>(tokenService.query(token));
    }

    @DeleteMapping("logout")
    public BaseDto logout(@RequestParam(name = "token") String token) {
        tokenService.delete(token);
        return new BaseDto();
    }
}
